package com.bingxue.edu.management.shop.activity;

import cn.hutool.json.JSONUtil;
import com.bingxue.edu.framework.common.util.CheckUtils;
import com.bingxue.edu.management.shop.model.entity.Activity;

/**
 * @author panbo
 * @since 2024/11/13
 */
public class ActivityUtil {

    /**
     * 获取活动配置
     */
    public static <R> R getActivityConfig(Activity activity, Class<R> asType) {
        CheckUtils.throwIfNull(activity, "活动不存在");
        String configStr = activity.getConfig() == null ? "{}" : activity.getConfig();
        return JSONUtil.toBean(configStr, asType);
    }
}
